package com.example.composableexample

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Divider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

/**
 * author: LiLiang
 * createTime: 2022/9/29-18:50
 * remark:
 **/

@Preview
@Composable
fun ColumnSimplePreview() {
    val list = listOf("A", "B", "C", "D")
    XxxItem(list = list) {
        Divider(thickness = 1.dp, modifier = Modifier.padding(horizontal = 16.dp))
    }
}

@Composable
fun XxxItem(list: List<String>, divider: @Composable () -> Unit) {
    Column(modifier = Modifier.fillMaxSize()) {
        list.forEachIndexed { index, s ->
            Text(text = s)
            if (index != list.lastIndex) {
                divider()
            }
        }
    }
}